{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3",
   "language": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "import fitz\n",
    "import time\n",
    "import re"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_pic_from_pdf(path,save_path):\n",
    "    file_name = path.split('\\\\')[-1].split(\".\")[0]\n",
    "    doc = fitz.open(path)\n",
    "    doc._getXrefLength()\n",
    "    # 图片计数\n",
    "    imgcount = 0\n",
    "    lenXREF = doc._getXrefLength()\n",
    "    t0 = time.time()\n",
    "    # 使用正则表达式来查找图片\n",
    "    checkXO = r\"/Type(?= */XObject)\" \n",
    "    checkIM = r\"/Subtype(?= */Image)\" \n",
    "    # 打印PDF的信息\n",
    "    print(\"文件名:{}, 页数: {}, 对象: {}\".format(path.split('/')[-1], len(doc), lenXREF - 1))\n",
    "\n",
    "    # 遍历每一个对象\n",
    "    for i in range(1, lenXREF):\n",
    "        # 定义对象字符串\n",
    "        # text = doc.getObjectString(i)\n",
    "        text = doc._getXrefString(i)\n",
    "        \n",
    "        isXObject = re.search(checkXO, text)\n",
    "        # 使用正则表达式查看是否是图片\n",
    "        isImage = re.search(checkIM, text)\n",
    "        # 如果不是对象也不是图片，则continue\n",
    "        if not isXObject or not isImage:\n",
    "            continue\n",
    "        imgcount += 1\n",
    "        # 根据索引生成图像\n",
    "        pix = fitz.Pixmap(doc, i)\n",
    "        # 根据pdf的路径生成图片的名称\n",
    "        # new_name = path.replace('\\\\', '_') + \"_img{}.png\".format(imgcount)\n",
    "        new_name =  file_name + \"_{}.png\".format(imgcount)\n",
    "        new_name = new_name.replace(':', '')\n",
    "\n",
    "        # 如果pix.n<5,可以直接存为PNG\n",
    "        if pix.n < 5:\n",
    "            pix.writePNG(os.path.join(save_path, new_name))\n",
    "            # pix.writePNG(new_name)\n",
    "        # 否则先转换CMYK\n",
    "        else:\n",
    "            pix0 = fitz.Pixmap(fitz.csRGB, pix)\n",
    "            pix0.writePNG(os.path.join(save_path, new_name))\n",
    "            pix0 = None\n",
    "        # 释放资源\n",
    "        pix = None\n",
    "        t1 = time.time()\n",
    "        print(\"运行时间:{}s\".format(t1 - t0))\n",
    "        print(\"提取了{}张图片\".format(imgcount))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "path = 'C:/Users/txp/Documents/Tencent Files/492350627/FileRecv/MobileFile/农作物病虫害数据库图象检索系统/农作物病虫害数据库图象检索系统/UpFiles/水稻矮缩病.pdf'\n",
    "save_path = 'C:/Users/txp/Documents/Tencent Files/492350627/FileRecv/MobileFile/农作物病虫害数据库图象检索系统/农作物病虫害数据库图象检索系统/UpFiles'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [],
   "source": [
    "import glob"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "file_list = glob.glob('C:/Users/txp/Documents/Tencent Files/492350627/FileRecv/MobileFile/农作物病虫害数据库图象检索系统/农作物病虫害数据库图象检索系统/UpFiles/*.pdf')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "文件名:UpFiles\\水稻一柱香病.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.010997533798217773s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻三化螟.pdf, 页数: 3, 对象: 30\n",
      "运行时间:0.009002685546875s\n",
      "提取了1张图片\n",
      "运行时间:0.018004894256591797s\n",
      "提取了2张图片\n",
      "运行时间:0.02800774574279785s\n",
      "提取了3张图片\n",
      "运行时间:0.03801107406616211s\n",
      "提取了4张图片\n",
      "运行时间:0.050031185150146484s\n",
      "提取了5张图片\n",
      "文件名:UpFiles\\水稻东格鲁病毒病.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.012000799179077148s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻中华稻蝗.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.009003639221191406s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻二化螟.pdf, 页数: 2, 对象: 25\n",
      "运行时间:0.012001752853393555s\n",
      "提取了1张图片\n",
      "运行时间:0.022002458572387695s\n",
      "提取了2张图片\n",
      "运行时间:0.0330047607421875s\n",
      "提取了3张图片\n",
      "文件名:UpFiles\\水稻云形病.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.014996767044067383s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻低温冷害.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.014002323150634766s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻倒伏.pdf, 页数: 2, 对象: 28\n",
      "运行时间:0.009015083312988281s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻台湾稻螟.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.009990692138671875s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻叶尖枯病.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.009002685546875s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻叶鞘网斑病.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.01501011848449707s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻叶鞘腐败病.pdf, 页数: 2, 对象: 26\n",
      "运行时间:0.011014461517333984s\n",
      "提取了1张图片\n",
      "运行时间:0.025011301040649414s\n",
      "提取了2张图片\n",
      "运行时间:0.03600811958312988s\n",
      "提取了3张图片\n",
      "运行时间:0.045009613037109375s\n",
      "提取了4张图片\n",
      "文件名:UpFiles\\水稻叶黑肿病.pdf, 页数: 1, 对象: 21\n",
      "运行时间:0.010004281997680664s\n",
      "提取了1张图片\n",
      "运行时间:0.019002437591552734s\n",
      "提取了2张图片\n",
      "文件名:UpFiles\\水稻周斑水虹.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.00900125503540039s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻大稻缘蝽.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.013007879257202148s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻大绿蝽.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.014005184173583984s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻大螟.pdf, 页数: 2, 对象: 25\n",
      "运行时间:0.008990049362182617s\n",
      "提取了1张图片\n",
      "运行时间:0.020989656448364258s\n",
      "提取了2张图片\n",
      "运行时间:0.03199267387390137s\n",
      "提取了3张图片\n",
      "文件名:UpFiles\\水稻小绿叶蝉.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.009014129638671875s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻山稻蝗.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.015995025634765625s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻干尖线虫病.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.01000356674194336s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻恶苗病.pdf, 页数: 2, 对象: 25\n",
      "运行时间:0.01000833511352539s\n",
      "提取了1张图片\n",
      "运行时间:0.018010854721069336s\n",
      "提取了2张图片\n",
      "运行时间:0.026018381118774414s\n",
      "提取了3张图片\n",
      "文件名:UpFiles\\水稻显纹纵卷叶螟.pdf, 页数: 1, 对象: 21\n",
      "运行时间:0.01800847053527832s\n",
      "提取了1张图片\n",
      "运行时间:0.028004884719848633s\n",
      "提取了2张图片\n",
      "文件名:UpFiles\\水稻条纹叶枯病.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.01400899887084961s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻根结线虫病.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.011008501052856445s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻灰飞虱.pdf, 页数: 1, 对象: 25\n",
      "运行时间:0.014003276824951172s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻烂秧病.pdf, 页数: 4, 对象: 31\n",
      "运行时间:0.011001110076904297s\n",
      "提取了1张图片\n",
      "运行时间:0.02300262451171875s\n",
      "提取了2张图片\n",
      "运行时间:0.04151296615600586s\n",
      "提取了3张图片\n",
      "文件名:UpFiles\\水稻田蚜虫.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.016002416610717773s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻电光叶蝉.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.012001991271972656s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻白叶枯病.pdf, 页数: 3, 对象: 30\n",
      "运行时间:0.01200246810913086s\n",
      "提取了1张图片\n",
      "运行时间:0.020003557205200195s\n",
      "提取了2张图片\n",
      "运行时间:0.03400874137878418s\n",
      "提取了3张图片\n",
      "运行时间:0.054013729095458984s\n",
      "提取了4张图片\n",
      "运行时间:0.06501603126525879s\n",
      "提取了5张图片\n",
      "文件名:UpFiles\\水稻白绢病.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.013003110885620117s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻白翅叶蝉.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.0223538875579834s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻白背飞虱.pdf, 页数: 1, 对象: 21\n",
      "运行时间:0.019004344940185547s\n",
      "提取了1张图片\n",
      "运行时间:0.03400540351867676s\n",
      "提取了2张图片\n",
      "文件名:UpFiles\\水稻直纹稻弄蝶.pdf, 页数: 2, 对象: 24\n",
      "运行时间:0.01400136947631836s\n",
      "提取了1张图片\n",
      "运行时间:0.029002666473388672s\n",
      "提取了2张图片\n",
      "文件名:UpFiles\\水稻矮缩病.pdf, 页数: 2, 对象: 24\n",
      "运行时间:0.011196136474609375s\n",
      "提取了1张图片\n",
      "运行时间:0.02334904670715332s\n",
      "提取了2张图片\n",
      "文件名:UpFiles\\水稻福寿螺.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.011008977890014648s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻禾蓟马.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.013002872467041016s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻巢螟.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.010083675384521484s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻曲病.pdf, 页数: 2, 对象: 24\n",
      "运行时间:0.012002706527709961s\n",
      "提取了1张图片\n",
      "运行时间:0.022003889083862305s\n",
      "提取了2张图片\n",
      "文件名:UpFiles\\水稻稻棘缘蝽.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.011000633239746094s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻水螟.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.01989459991455078s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻水象甲.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.010004997253417969s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻潜叶蝇.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.01500248908996582s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻田棉铃虫.pdf, 页数: 1, 对象: 21\n",
      "运行时间:0.01399993896484375s\n",
      "提取了1张图片\n",
      "运行时间:0.03637862205505371s\n",
      "提取了2张图片\n",
      "文件名:UpFiles\\水稻稻田粘虫.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.02300572395324707s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻瘟病.pdf, 页数: 5, 对象: 45\n",
      "运行时间:0.011000394821166992s\n",
      "提取了1张图片\n",
      "运行时间:0.026003360748291016s\n",
      "提取了2张图片\n",
      "运行时间:0.0420074462890625s\n",
      "提取了3张图片\n",
      "运行时间:0.05552387237548828s\n",
      "提取了4张图片\n",
      "运行时间:0.0725247859954834s\n",
      "提取了5张图片\n",
      "运行时间:0.08852982521057129s\n",
      "提取了6张图片\n",
      "运行时间:0.10453343391418457s\n",
      "提取了7张图片\n",
      "运行时间:0.12253642082214355s\n",
      "提取了8张图片\n",
      "运行时间:0.1325397491455078s\n",
      "提取了9张图片\n",
      "运行时间:0.14954423904418945s\n",
      "提取了10张图片\n",
      "运行时间:0.16054606437683105s\n",
      "提取了11张图片\n",
      "运行时间:0.17354679107666016s\n",
      "提取了12张图片\n",
      "运行时间:0.18255233764648438s\n",
      "提取了13张图片\n",
      "运行时间:0.19156455993652344s\n",
      "提取了14张图片\n",
      "文件名:UpFiles\\水稻稻瘿蚊.pdf, 页数: 3, 对象: 27\n",
      "运行时间:0.01200103759765625s\n",
      "提取了1张图片\n",
      "运行时间:0.025004863739013672s\n",
      "提取了2张图片\n",
      "文件名:UpFiles\\水稻稻白粉虱.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.012003421783447266s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻直鬃蓟马.pdf, 页数: 2, 对象: 24\n",
      "运行时间:0.013002395629882812s\n",
      "提取了1张图片\n",
      "运行时间:0.025003433227539062s\n",
      "提取了2张图片\n",
      "文件名:UpFiles\\水稻稻眼蝶.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.011003255844116211s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻秆潜蝇.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.017935752868652344s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻筒水螟.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.021006107330322266s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻简管蓟马.pdf, 页数: 2, 对象: 24\n",
      "运行时间:0.011004209518432617s\n",
      "提取了1张图片\n",
      "运行时间:0.04321718215942383s\n",
      "提取了2张图片\n",
      "文件名:UpFiles\\水稻稻粒黑粉病.pdf, 页数: 2, 对象: 24\n",
      "运行时间:0.012001752853393555s\n",
      "提取了1张图片\n",
      "运行时间:0.02800583839416504s\n",
      "提取了2张图片\n",
      "文件名:UpFiles\\水稻稻纵卷叶螟.pdf, 页数: 3, 对象: 32\n",
      "运行时间:0.01100301742553711s\n",
      "提取了1张图片\n",
      "运行时间:0.023004531860351562s\n",
      "提取了2张图片\n",
      "运行时间:0.03700995445251465s\n",
      "提取了3张图片\n",
      "运行时间:0.04900932312011719s\n",
      "提取了4张图片\n",
      "运行时间:0.05901193618774414s\n",
      "提取了5张图片\n",
      "运行时间:0.07201480865478516s\n",
      "提取了6张图片\n",
      "运行时间:0.08101773262023926s\n",
      "提取了7张图片\n",
      "文件名:UpFiles\\水稻稻绿蝽.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.014003276824951172s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻苗疫病.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.010002374649047852s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻褐飞虱.pdf, 页数: 2, 对象: 26\n",
      "运行时间:0.0030028820037841797s\n",
      "提取了1张图片\n",
      "运行时间:0.015004634857177734s\n",
      "提取了2张图片\n",
      "运行时间:0.03400850296020508s\n",
      "提取了3张图片\n",
      "运行时间:0.03600811958312988s\n",
      "提取了4张图片\n",
      "文件名:UpFiles\\水稻稻象甲.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.018001079559326172s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻负泥甲.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.012004613876342773s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻赤斑沫蝉.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.015002012252807617s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻金翅夜蛾.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.014000415802001953s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻铁甲虫.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.01000070571899414s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻稻黑蝽.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.015004158020019531s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻窄条斑病.pdf, 页数: 2, 对象: 24\n",
      "运行时间:0.009001970291137695s\n",
      "提取了1张图片\n",
      "运行时间:0.0220029354095459s\n",
      "提取了2张图片\n",
      "文件名:UpFiles\\水稻端大蓟马.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.01100015640258789s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻紫鞘病.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.014002323150634766s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻纹枯病.pdf, 页数: 3, 对象: 28\n",
      "运行时间:0.009001731872558594s\n",
      "提取了1张图片\n",
      "运行时间:0.02300572395324707s\n",
      "提取了2张图片\n",
      "运行时间:0.03500699996948242s\n",
      "提取了3张图片\n",
      "文件名:UpFiles\\水稻细菌性基腐病.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.013001203536987305s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻细菌性条斑病.pdf, 页数: 2, 对象: 24\n",
      "运行时间:0.015003681182861328s\n",
      "提取了1张图片\n",
      "运行时间:0.028005123138427734s\n",
      "提取了2张图片\n",
      "文件名:UpFiles\\水稻细菌性褐斑病.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.011061429977416992s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻细菌性褐条病.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.009133100509643555s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻细菌性谷枯病.pdf, 页数: 1, 对象: 21\n",
      "运行时间:0.015002012252807617s\n",
      "提取了1张图片\n",
      "运行时间:0.025004863739013672s\n",
      "提取了2张图片\n",
      "文件名:UpFiles\\水稻胡麻斑病.pdf, 页数: 2, 对象: 25\n",
      "运行时间:0.015002727508544922s\n",
      "提取了1张图片\n",
      "运行时间:0.02700638771057129s\n",
      "提取了2张图片\n",
      "运行时间:0.036006927490234375s\n",
      "提取了3张图片\n",
      "文件名:UpFiles\\水稻芋蝗.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.009000301361083984s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻花蓟马.pdf, 页数: 1, 对象: 21\n",
      "运行时间:0.010092973709106445s\n",
      "提取了1张图片\n",
      "运行时间:0.025095224380493164s\n",
      "提取了2张图片\n",
      "文件名:UpFiles\\水稻菌核秆腐病.pdf, 页数: 3, 对象: 30\n",
      "运行时间:0.010002374649047852s\n",
      "提取了1张图片\n",
      "运行时间:0.020005226135253906s\n",
      "提取了2张图片\n",
      "运行时间:0.03201484680175781s\n",
      "提取了3张图片\n",
      "运行时间:0.0420231819152832s\n",
      "提取了4张图片\n",
      "运行时间:0.05401754379272461s\n",
      "提取了5张图片\n",
      "文件名:UpFiles\\水稻菲岛毛眼水蝇.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.012011051177978516s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻营养障碍.pdf, 页数: 4, 对象: 39\n",
      "运行时间:0.009000301361083984s\n",
      "提取了1张图片\n",
      "运行时间:0.018000364303588867s\n",
      "提取了2张图片\n",
      "运行时间:0.0289919376373291s\n",
      "提取了3张图片\n",
      "运行时间:0.037993669509887695s\n",
      "提取了4张图片\n",
      "运行时间:0.04601097106933594s\n",
      "提取了5张图片\n",
      "运行时间:0.06499910354614258s\n",
      "提取了6张图片\n",
      "运行时间:0.07400226593017578s\n",
      "提取了7张图片\n",
      "运行时间:0.08600544929504395s\n",
      "提取了8张图片\n",
      "运行时间:0.09500718116760254s\n",
      "提取了9张图片\n",
      "运行时间:0.10700869560241699s\n",
      "提取了10张图片\n",
      "运行时间:0.1160123348236084s\n",
      "提取了11张图片\n",
      "文件名:UpFiles\\水稻褐边螟.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.010013580322265625s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻谷枯病.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.008989572525024414s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻赤枯病.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.011999845504760742s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻长绿飞虱.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.014002561569213867s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻长肩棘缘熔和短肩棘缘蝽.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.013005495071411133s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻长腿水叶甲.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.010000467300415039s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻霜霉病.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.011000633239746094s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻青枯病.pdf, 页数: 1, 对象: 19\n",
      "文件名:UpFiles\\水稻高温热害.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.009183883666992188s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻鳃蚯蚓.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.00900411605834961s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻黄叶病.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.008001089096069336s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻黄萎病.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.008001089096069336s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻黑尾叶蝉.pdf, 页数: 2, 对象: 23\n",
      "运行时间:0.013005495071411133s\n",
      "提取了1张图片\n",
      "文件名:UpFiles\\水稻黑条矮缩病.pdf, 页数: 1, 对象: 19\n",
      "文件名:UpFiles\\水稻齿矮病.pdf, 页数: 1, 对象: 20\n",
      "运行时间:0.008999347686767578s\n",
      "提取了1张图片\n"
     ]
    }
   ],
   "source": [
    "for filename in file_list:\n",
    "    get_pic_from_pdf(filename,save_path)"
   ]
  }
 ]
}